# Makefile for HEX Parser
CXX = g++
CXXFLAGS = -std=c++11 -Wall -Wextra -O2
TARGET = hex_parser
SOURCES = main.cpp hex_parser.cpp
OBJECTS = $(SOURCES:.cpp=.o)

# 默认目标
all: $(TARGET)

# 编译目标
$(TARGET): $(OBJECTS)
	$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJECTS)

# 编译源文件
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# 清理
clean:
	rm -f $(OBJECTS) $(TARGET)

# 运行测试
test: $(TARGET)
	./$(TARGET) M6_HMI_LOADER.hex

# 安装 (可选)
install: $(TARGET)
	cp $(TARGET) /usr/local/bin/

# 帮助
help:
	@echo "可用的目标:"
	@echo "  all     - 编译程序 (默认)"
	@echo "  clean   - 清理编译文件"
	@echo "  test    - 编译并运行测试"
	@echo "  install - 安装到系统"
	@echo "  help    - 显示此帮助信息"

.PHONY: all clean test install help
